package com.lmm.lcuser.lc_user;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.view.MenuItem;
import com.lmm.dresswisdom.lmmframe.base.BaseCompatActivity;

/**
 * Created by xmgong on 2017/8/29.
 */

public class AppBaseActivity extends BaseCompatActivity {

    public ActionBar actionBar;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        actionBar = getSupportActionBar();
        setAppActionBar();
        //个推初始化
//        PushManager.getInstance().initialize(this.getApplicationContext(),
//                DemoPushService.class);
//        PushManager.getInstance().registerPushIntentService(this.getApplicationContext(),
//                DemoIntentService.class);
    }

    public void setActionBarTitle(String title) {
        if (actionBar != null) {
            actionBar.setTitle(title);
        }
    }

    @Override
    public void hideActionBar() {
        super.hideActionBar();
    }

    public void setAppActionBar() {
        if (actionBar != null) {
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                backAction();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void showDefaultDialog() {
        super.showDefaultDialog();
    }

    @Override
    public void hideDefaultDialog() {
        super.hideDefaultDialog();
    }

    public void backAction() {
        finish();
    }

}
